Jet().$package('app',function(J){
	var $=J.dom.id,
		$D=J.dom,
		$E=J.event,
		$U=J.ui,
		$tool=J.tool,
		$appCurrent=app.current,
		$appHistory=app.history,
		$appMember=app.member;
	this.memberKV = {};
	
	//加载
	$E.onDomReady(function(){
		app.initMemberKV();	//初始化成员键值
		
		//初始化Tab
		var tab = new $U.Tab();
		tab.setConfig({'defaultIndex':0,'repeatTrigger':true});
		tab.add({trigger:$('tab_current'), sheet:$('current')});
		tab.add({trigger:$('tab_history'), sheet:$('history')});
		tab.add({trigger:$('tab_member'), sheet:$('member')});
		$E.addObserver(tab, "show", function(a){
			switch(this.indexOf(a)){
				case 0:
					$appCurrent.listCurrent(1);
					break;
				case 1:
					$appHistory.listHistory(1);
					break;
				case 2:
					$appMember.listMember();
					//$app.alertMsg('操作成功');
					//var oDialog = J.ui.dialog({'divNode':$('msg_box'), 'title':'提示'});
					//var oDialog = J.ui.dialog({'divNode':$('ronnylay'), 'title':'小组成员', 'width':'400px', 'height':'200px'});
					break;
			}
		});
		tab.init();
		
		//绑定账单组change事件
		$E.on($('sel_group'), 'change', function(){
			app.initMemberKV();
			tab.selectIndex(0);
		});
	});	
	
	//账单组成员键值
	this.initMemberKV = function(){
		var context = this;
		var uri = '/ajax.php?d=group&c=GroupProxy&f=memberKV&group_id='+$('sel_group').value;
		$tool.get(uri,function(response){
			if(response.result==1){
				context.memberKV = response.data;
			}
		});
	};
	
	
});